package com.wn.pettyloan.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wn.pettyloan.dto.DebitDto;
import com.wn.pettyloan.entity.Debit;
import com.wn.pettyloan.service.DebitService;
import com.wn.pettyloan.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: pettyloan
 * @ClassName DebitController
 * @author: lwb
 * @create: 2022-12-12 14:57
 **/
@Api(tags = "借款申请以及借款")

@RestController
@RequestMapping("/debit")
public class DebitController {
    @Autowired
    private DebitService debitService;

    @ApiOperation("根据条件查询debit")
    @PostMapping("/find")
    public Result findByDto(@RequestBody DebitDto debitDto){
        PageHelper.startPage(debitDto.getCurrentPage(),debitDto.getPageSize());
        List<Debit> debits= debitService.findByDto(debitDto);

        return Result.ok().data("pageInfo",new PageInfo<Debit>(debits));
    }


}
